package com.runda.partypolicy.app.others;


import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * author:  RD_CY
 * date:    2018/1/11
 * version: v1.0
 * description:
 */

public class CommonMethods {


    /**
     * 时间错转日期
     *
     * @param seconds 时间戳
     * @param format   指定日期格式
     * @return
     */
    public static String timeStamp2DateSecond(String seconds, String format) {
        if (seconds == null || seconds.isEmpty() || seconds.equals("null")) {
            return "";
        }
        if (format == null || format.isEmpty()) {
            format = "yyyy-MM-dd HH:mm:ss";
        }
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        return sdf.format(new Date(Long.valueOf(seconds + "000")));
    }
    public static String timeStamp2DateDay(String seconds, String format) {
        if (seconds == null || seconds.isEmpty() || seconds.equals("null")) {
            return "";
        }
        if (format == null || format.isEmpty()) {
            format = "yyyy-MM-dd HH:mm:ss";
        }
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        return sdf.format(new Date(Long.valueOf(seconds)));
    }

}
